
const isEmpty = (data) => {
    if (data === null || data === undefined) {
        return true; // null 和 undefined
    }

    if (typeof data === 'string') {
        return data.trim() === ''; // 空字符串
    }

    if (Array.isArray(data)) {
        return data.length === 0; // 空数组
    }

    if (typeof data === 'object') {
        return Object.keys(data).length === 0; // 空对象
    }

    return false; // 其他类型数据（例如数字）不认为是空
}


//计算当前几岁
const age = (birth) => {
    const now = new Date()
    const birthday = new Date(birth)
    const age = now.getFullYear() - birthday.getFullYear()
    return age || 0
}
//计算什么星座
const constellation = (birthday) => {
    const month = new Date(birthday).getMonth() + 1
    const constellationMap = {
        1: '摩羯座',
        2: '水瓶座',
        3: '双鱼座',
        4: '白羊座',
        5: '金牛座',
        6: '双子座',
        7: '巨蟹座',
        8: '狮子座',
        9: '处女座',
        10: '天秤座',
        11: '天蝎座',
        12: '射手座',
    }
    const constellationArr = Object.keys(constellationMap).map(Number)
    const index = constellationArr.findIndex(item => item > month)
    return constellationMap[constellationArr[index - 1]]
}




export {
    isEmpty,
    age,
    constellation,
}